package com.ustb.springboot.controller;

import com.ustb.springboot.common.utils.R;
import com.ustb.springboot.entity.AnswerScoreEntity;
import com.ustb.springboot.service.AnswerScoreService;
import org.apache.shiro.authz.annotation.RequiresPermissions;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.servlet.http.HttpServletRequest;
import java.util.HashMap;
import java.util.Map;


/**
 * @author pyn
 * @date 2022-05-17 11:26:55
 */
@RestController
@RequestMapping("answerscore")
public class AnswerScoreController {
    @Autowired
    private AnswerScoreService answerScoreService;


    /**
     * 保存
     */
    @RequestMapping("/save")
    @RequiresPermissions("answerscore:save")
    public R save(HttpServletRequest request, @RequestBody AnswerScoreEntity answerScore) {
        return answerScoreService.save(request, answerScore);
    }


    /**
     * 删除
     */
    @RequestMapping("/delete")
    @RequiresPermissions("answerscore:delete")
    public R delete(@RequestBody Map<String, Object> body) {
        return answerScoreService.delete(body);
    }

    @RequestMapping("/summerize")
    @RequiresPermissions("answerscore:summerize")
    public R summerize(@RequestBody Map<String, Object> body){
        Map<String,Object> summerizeScore = new HashMap<String , Object>();
        summerizeScore = answerScoreService.summerize(body);
        if (null == summerizeScore)
            return R.ok(2000, "暂无信息!");
        else
            return R.ok(20000, "查询成功!").put("summerize_score",summerizeScore);
    }
}
